<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    意见反馈类型 模型
 *    Date: 2018/9/6
 * Class OpiniontypeModel
 * @package app\common\model
 */
class OpiniontypeModel extends Model
{
    // 表名
    protected $name = 'opinion_type';

    // 列表查询
    public function getAll($where, $field, $page, $pageSize, $order)
    {
        $result = Db::name($this->name)
            ->where($where)
            ->field($field)
            ->page($page, $pageSize)
            ->order($order)
            ->select();
        return $result;
    }

    // 数量查询
    public function getCount($where)
    {
        $result = Db::name($this->name)
            ->where($where)
            ->count();
        return $result;
    }

    // 单条查询
    public function getOne($where, $field='*')
    {
        $result = Db::name($this->name)
            ->where($where)
            ->field($field)
            ->find();
        return $result;
    }

    // 添加操作
    public function add($data)
    {
        $result = Db::name($this->name)->insertGetId($data);
        return $result;
    }

    // 编辑操作
    public function edit($where, $data)
    {
        $result = Db::name($this->name)->where($where)->update($data);
        return $result;
    }

}